package          ghf
import    ru.mipt.board.net._
import   scala.actors._
import actors.Actor._
import java.sql.{Connection,DriverManager}
import org.squeryl.PrimitiveTypeMode._
import org.squeryl.adapters.MySQLAdapter
import org.squeryl._

/**
 * Created by IntelliJ IDEA.
 * User: IL
 * Date: 12.09.2010
 * Time: 11:24:40
 * To change this template use File | Settings | File Templates.
 */

object test   extends Application    {
  /*    val a = new MainActor
        a.start
    val numactors = 50
    val numposts = 6777777
     val workers = new Array[WorkingActor](numactors)
    for (i <- 0 to (numactors - 1) ) {
        workers(i) = new  WorkingActor
        workers(i).start
        workers(i) ! (i*numactors/numactors,a)
    }


    Thread.sleep(5000)   */
    Class.forName("com.mysql.jdbc.Driver");
    val connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/test?user=root&password=qaz")
    connection.setTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED)

    var s:Query[String]    = _
    var qaz:String      = _
    using(Session.create(connection,new MySQLAdapter)){
        import testdb._
        testdb.drop
       try{
        testdb.create

         testtable.insert(new BoardMessage(5,"fdsg","text",45,None,"head"))
        testtable.insert(new BoardMessage(6,"fdsg","text",45,None,"head"))
        testtable.insert(new BoardMessage(7,"fdsg","text",45,None,"head"))
        testtable.insert(new BoardMessage(58,"fdsg","text",45,None,"head"))



         //
    }
    catch{ case a => println(a)
    }
        val q = 4 +98
    }
    using(Session.create(connection,new MySQLAdapter)){
       s = from(testdb.testtable)(a => where(a.ID ===  5) select(a.text))
    qaz = s.head}

      val c = 4 +5

}


object  testdb extends Schema{
    val testtable = table[BoardMessage]
    override def drop = super.drop
}